package com.bristua.mall.user.biz;

import com.bristua.mall.common.utils.CacheUtil;
import com.bristua.mall.common.utils.DateUtil;
import com.bristua.mall.common.utils.SequenceUtil;
import com.bristua.mall.user.dao.TUserBankMapper;
import com.bristua.mall.user.model.TUser;
import com.bristua.mall.user.model.TUserBank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/3/24.
 */
@Service
@Transactional
public class AddUserBankBiz {

    @Resource
    private TUserBankMapper tUserBankMapper;

    @Autowired
    private CacheUtil cacheUtil;

    public void addUserBank(TUserBank tUserBank){
        TUser userSession = (TUser) cacheUtil.getUserSession();
        tUserBank.setUserBankId(SequenceUtil.nextId());
        tUserBank.setUserId(userSession.getUserId());//用户ID
        tUserBank.setBankStatus("1");
        tUserBank.setCreateTime(DateUtil.getDateTime3());
        tUserBankMapper.insert(tUserBank);
    }
}
